#include <iostream>
#include <malloc.h>

using namespace std;
const static int M=15,N=20;

void _kp(int* p, int n, int m)
{
	//cout<<"n: "<<n<<"m: "<<m<<endl;
	if(n<0||m<0)
		return;
	else if(m==0)
	{
		for(int i=1;i<=N;i++)
			if(p[i])	
				cout<<i<<" ";
		cout<<endl;
		return;
	}
	p[n] = 1;
	_kp(p, n-1, m-n);
	p[n] = 0;
	_kp(p, n-1,m);
}

void kp(int *p, int n, int m)
{
	if(m<n)
		return _kp(p, m, m);
	else return _kp(p, n, m);
}

int main()
{
	int *p=(int *)malloc((N+1)*sizeof(int));
	for(int i=1;i<=N;i++)
		p[i]=0;
	kp(p, N, M);
}
